////////////////////////////////////////////////////////////////////////////
//
//  Crytek Engine Source File.
//  Copyright (C), Crytek Studios, 2010.
// -------------------------------------------------------------------------
//  File name:   DeferredCollisionEvent.h
//  Version:     v1.00
//  Created:     12/08/2010 by Christopher Bolte
//  Compilers:   Visual Studio.NET
// -------------------------------------------------------------------------
//  History:
////////////////////////////////////////////////////////////////////////////

#ifndef _3DENGINE_DEFERREDCOLLISIONEVENT_H_
#define _3DENGINE_DEFERREDCOLLISIONEVENT_H_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <IDeferredCollisionEvent.h>

// Implementation class for the DeferredPhysicsEvent Manager
class CDeferredPhysicsEventManager : public IDeferredPhysicsEventManager,  public Cry3DEngineBase
{
public:	
	CDeferredPhysicsEventManager();
	virtual ~CDeferredPhysicsEventManager();

	VIRTUAL void DispatchDeferredEvent( IDeferredPhysicsEvent *pEvent );
	VIRTUAL int HandleEvent( const EventPhys *pEvent, IDeferredPhysicsEventManager::CreateEventFunc, IDeferredPhysicsEvent::DeferredEventType);

	VIRTUAL void RegisterDeferredEvent(IDeferredPhysicsEvent *pDeferredEvent );
	VIRTUAL void UnRegisterDeferredEvent(IDeferredPhysicsEvent *pDeferredEvent );

	VIRTUAL void ClearDeferredEvents();

	VIRTUAL void Update();

	VIRTUAL IDeferredPhysicsEvent* GetLastCollisionEventForEntity(IPhysicalEntity *pPhysEnt);

private:
	ThreadPoolHandle m_hThreadPool;																// thread pool to use for deferred event tasks
	std::vector<IDeferredPhysicsEvent*> m_activeDeferredEvents;		// list of all active deferred events, used for cleanup and statistics
};

#endif // _3DENGINE_DEFERREDCOLLISIONEVENT_H_